use super::*;

pub(crate) fn expand(input: &mut ItemType) -> TokenStream {
	let ty = LitStr::new(&input.ident.to_string(), Span::call_site());
	let target = LitStr::new(&input.ty.to_token_stream().to_string(), Span::call_site());
	#[cfg(feature = "dts")]
	let dts = build_dts(dts(input));
	#[cfg(not(feature = "dts"))]
	let dts = TokenStream::new();
	quote! {
		#input
		::napih::REG_TYPE!(#ty,#target);
		#dts
	}
}
#[cfg(feature = "dts")]
fn dts(input: &mut ItemType) -> DTSResult {
	let name = input.ts();
	let ret = input.ty.try_ts().ok_or("type ty")?;
	Ok(fomat!("export type "(name)" = "(ret)";").without(name, TY_TYPE))
}
